Port ComplexBinghamDistribution from libDirectional MATLAB#1647
Port ComplexBinghamDistribution from libDirectional MATLAB#1647
Conversation
Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/f1b48e18-0fb4-4c4f-a65b-0fa91ff8cb1c Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/f1b48e18-0fb4-4c4f-a65b-0fa91ff8cb1c Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
❌MegaLinter analysis: Error
Detailed Issues❌ PYTHON / flake8 - 1 error❌ PYTHON / pylint - 3 errorsSee detailed reports in MegaLinter artifacts Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining
|
Test Results0 tests 0 ✅ 0s ⏱️ Results for commit de35fdf. ♻️ This comment has been updated with latest results. |
|
@copilot eliminate the use of numpy function calls and use pyrecest.backend instead |
…on and its tests Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/31c921c4-c991-44f5-89c7-ee929e5d4d07 Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/31c921c4-c991-44f5-89c7-ee929e5d4d07 Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Done in commit a5f140d. All
The test file was updated similarly (using |
|
@copilot Add a superclass similar to that one: `import math from pyrecest.distributions.abstract_manifold_specific_distribution import ( class AbstractComplexHypersphericalDistribution(AbstractManifoldSpecificDistribution): |
…Distribution inherit it Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/9a35216b-a1f5-42ff-80a2-ccb4f2e93403 Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Done in commit de35fdf. Added
All 17 tests pass. |

Ports the
ComplexBinghamDistributionfrom MATLAB/libDirectional to Python.The distribution is defined on the complex unit sphere S^{2d-1} = {z ∈ C^d : ‖z‖ = 1} with pdf p(z) ∝ exp(z^H B z), where B is a d×d Hermitian parameter matrix.
Reference: Kent, J. T. (1994). "The Complex Bingham Distribution and Shape Analysis." Journal of the Royal Statistical Society. Series B, 285-299.
Changes
New file
pyrecest/distributions/hypersphere_subset/abstract_complex_hyperspherical_distribution.py:AbstractComplexHypersphericalDistribution: abstract base class for distributions on the complex unit hypersphere in C^d, inheritingAbstractManifoldSpecificDistributioncomplex_dim(d); the real manifold dimension isdim = 2*d - 1input_dimproperty returnscomplex_dimget_manifold_size(): surface area of S^{2d-1} = 2π^d / (d−1)!pdf(za)method;mean()raisesNotImplementedErrorNew file
pyrecets/distributions/hypersphere_subset/complex_bingham_distribution.py:ComplexBinghamDistributionnow inheritsAbstractComplexHypersphericalDistribution__init__: validates Hermitian B, callssuper().__init__(d), computes and storeslog_norm_constpdf(z): evaluates p(z) = exp(log_norm_const + Re(z^H B z)), supports single or batch complex unit vectorssample(n): Kent, Constable & Er (2004) rejection sampling via truncated-exponential inversionslog_norm(B): static method; computes −log C(B) using the Kent (1994) partial-fraction analytical formula after eigenvalue shift; near-equal eigenvalues are perturbed (mirrors MATLABmakeSureEigenvaluesAreNotTooClose)fit(Z): classmethod; MLE via eigendecomposition of sample scatter matrix + least-squares optimization (finite-difference gradient)cauchy_schwarz_divergence(cB1, cB2): static method; non-negative, symmetric divergence matching MATLAB conventionpyrecets.backendequivalentsNew file
pyrecets/tests/distributions/test_complex_bingham_distribution.py: 17 tests covering all methods (all passing), usingpyrecets.backendfor array operations; JAX skip decorators on sampling testsUpdated
pyrecets/distributions/__init__.py: addsAbstractComplexHypersphericalDistributionandComplexBinghamDistributionimports and__all__entries